﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CESelfDestoryObejct : MonoBehaviour
{
	[Tooltip ("当前Go是否为粒子系统")]
	public bool isParticle;

	[Tooltip ("是否在播放结束后自我删除")]
	public bool isDestoryWhenFinish;


	private ParticleSystem ps;

	// Use this for initialization
	void Start ()
	{
		if (isParticle) {
			ps = GetComponent<ParticleSystem> ();
		}
	}
	
	// Update is called once per frame
	void Update ()
	{
		if (isParticle && isDestoryWhenFinish && !ps.isPlaying) {
			Destroy (gameObject);
		}
	}
}
